package puzzle.slilin2.data;

/**
 * 線セルの状態
 * 
 * @author tomoto
 */
public class LineCellState extends CellState {
    private boolean m_isForbidden = false;
    private boolean m_exists = false;
    private boolean m_isAssumed = false;

	public LineCellState() {
    }

    public boolean exists() {
        return m_exists;
    }

    public boolean setExists(boolean exists) {
    	if (m_exists == exists) {
    		return false;
    	} else {
    		m_exists = exists;
    		m_isForbidden = !exists;
    		m_isDirty = true;
    		return true;
    	}
    }

    public boolean isForbidden() {
        return m_isForbidden;
    }

    public boolean setForbidden(boolean isForbidden) {
    	if (m_isForbidden == isForbidden) {
    		return false;
    	} else {
    		m_isForbidden = isForbidden;
    		m_exists = !isForbidden;
    		m_isDirty = true;
    		return true;
    	}
    }
    
    public boolean isFixed() {
    	return m_isForbidden || m_exists;
    }

    @Override
    public void copyFrom(CellState s) {
		LineCellState lcs = (LineCellState) s;
		super.copyFrom(s);
		m_exists = lcs.m_exists;
		m_isForbidden = lcs.m_isForbidden;
		m_isAssumed = lcs.m_isAssumed;
    }
    
	@Override
	public CellState dup() {
		LineCellState s = new LineCellState();
		s.copyFrom(this);
		return s;
	}

	public boolean isAssumed() {
		return m_isAssumed;
	}

	public void setAssumed(boolean assumed) {
		m_isAssumed = assumed;
	}

}
